﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Net.Chirash.Twitter.TwitterClient;
using Net.Chirash.Twitter.TwitterDatabase;

namespace Net.Chirash.Twitter.TweetZone.WindowComponents
{
    /// <summary>
    /// DirectMessageBox.xaml の相互作用ロジック
    /// </summary>
    public partial class DirectMessageBox : UserControl
    {
        #region Constructor

        /// <summary>
        /// DirectMessageBoxを作成します。表示するデータは引数のDirectMessageに対応します。
        /// </summary>
        /// <param name="directMessage">データの元になるDirectMessage</param>
        public DirectMessageBox(DirectMessage directMessage)
            : this()
        {
            DataContext = directMessage;
        }

        public DirectMessageBox()
        {
            InitializeComponent();
        }

        #endregion

        #region Private Methods

        private void Delete()
        {
            try
            {
                TwitterCommand command = new TwitterCommand(App.CurrentApp.Connection);
                command.Destroy((Status)DataContext);
            }
            catch (Exception ex)
            {
                //TODO:Show in TextBox
            }
        }

        #endregion

        #region Private Events

        private void ThumbGrid_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            Delete();
        }

        private void DeleteMenuItem_Click(object sender, RoutedEventArgs e)
        {
            Delete();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {

        }

        #endregion

    }
}
